package com.luo.controller;

import com.alibaba.fastjson.JSON;
import com.luo.model.TwoClass;
import com.luo.service.ClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 功能：
 * 作者：Luo。
 * 日期：2024/1/12 17:12
 */
@WebServlet("/queryTwoClassByOneName")
public class ClassTwoListController extends HttpServlet {

    ClassService classService = new ClassService();

    @Override
    protected void service(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
        String name = req.getParameter("oneClassName");
        List<TwoClass> twoClasses = classService.queryTwoClassByOneName(name);
        String jsonString = JSON.toJSONString(twoClasses);
        resp.getWriter().write(jsonString);
        resp.getWriter().close();
    }
}
